package com.hoshiicloud.auth.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.UsersLoginVO;
import com.hoshiicloud.auth.feign.fallback.HystrixUserFeignFallback;
import com.hoshiicloud.auth.vo.TokenUsersVO;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.user.dto.userCenter.MemberDto;
import com.hoshiicloud.user.entity.company.ComUsers;
import com.hoshiicloud.user.entity.company.Company;
import com.hoshiicloud.user.entity.company.Member;
import com.hoshiicloud.user.entity.platform.PlatUsers;
import com.hoshiicloud.user.param.PlatUsersParam;
import com.hoshiicloud.user.param.company.CompanyPageParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(name = "hoshiicloud-user", fallback = HystrixUserFeignFallback.class)
@Repository
public interface UserFeignService {

    @PostMapping(value = "/rbac/sys-users/getLoginDetail")
    Response<UsersLoginVO> getSysUser(String userName);

    @PostMapping(value = "/rbac/com-users/getLoginDetail")
    Response<UsersLoginVO> getComUser(String userName);

    @PostMapping(value = "/rbac/member/getStoreLoginDetail")
    Response<TokenUsersVO> getStoreMemberUser(@RequestBody Map<String, Object> map);

    @PostMapping(value = "/rbac/member/getPlatformLoginDetail")
    Response<TokenUsersVO> getPlatformMemberUser(@RequestBody Map<String, Object> map);

    @PostMapping(value = "/rbac/com-users/getComUserLoginDetail")
    Response<TokenUsersVO> getCompanyUser(@RequestBody Map<String, String> map);


    @PostMapping(value = "/platform/platUsers/getPage")
    Response<Page<PlatUsers>> getPlatUsersPage(PlatUsersParam param);

    /**
     * 根据手机号码查询租户会员
     *
     * @param companyId 租户id
     * @param mobile    手机号码
     * @return Response<MemberDto>
     */
    @RequestMapping(value = "/rbac/member/getMemberByMobile", method = RequestMethod.GET)
    Response<MemberDto> getMemberByMobile(@RequestParam("companyId") Long companyId, @RequestParam("mobile") String mobile);

    /*
     * @param member 会员实体
     * @return com.hoshiicloud.common.rpc.Response<java.util.List<com.hoshiicloud.user.entity.company.Member>>
     * @author: Mr.wu
     * @descripton: 根据条件查找租户会员列表
     * @date: 16:56 2019/8/26
     */
    @PostMapping(value = "/rbac/member/getMembers")
    Response<List<Member>> getMemberList(@RequestBody Member member);

    @PostMapping(value = "/company/company/list")
    Response<Page<Company>> getCompanyList(@RequestBody CompanyPageParam param);

    /**
     * 获取租户管理系统账号
     *
     * @param subDomain subDomain
     * @param userName  userName
     * @param password  password
     * @return Response
     */
    @PostMapping(value = "/rbac/com-users/getCompanyUserList")
    Response getCompanyUserList(@RequestParam("subDomain") String subDomain, @RequestParam("userName") String userName,
            @RequestParam("password") String password);

    /**
     * 获取租户管理系统账号
     *
     * @param comUsers comUsers
     * @return Response
     */
    @PostMapping(value = "/rbac/com-users/getCompanyUserListByModel")
    Response getCompanyUserListByModel(@RequestBody ComUsers comUsers);

}
